<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/9/5 0005
 * Time: 下午 7:25
 */
defined('BASEPATH') OR exit('No direct script access allowed');
class Contact extends MY_Controller
{
    /**
     * 初始化操作
     * */
    public function __construct()
    {
        parent::__construct();
        $this->load->database();
        $this->load->helper('url');
        $this->load->helper('captcha');
    }

    /**
     *所有留言显示
     * */
    public function index()

    {
        $data['title']='留言管理';
        //分页
        $this->load->library('pagination');
        $perPage =5;
        //$config['base_url'] = "http://127.0.0.1/study/htdocs/php5/ci/index.php/floor/index";
        $config['base_url'] = site_url().'/admin/contact/index';
        // 计算总记录数
        $config['total_rows'] = $this->db->count_all_results('content');
        $config['per_page'] =$perPage;
        $config['first_link'] = '第一页';
        $config['prev_link'] = '上一页';
        $config['next_link'] = '下一页';
        $config['last_link'] = '最后一页';
        $this->pagination->initialize($config);
        $links = $this->pagination->create_links();
        $offset = $this->uri->segment(4);
         $this->db->limit($perPage,$offset);
        //查看须在后
       
        // 查询所有的数据
       $content=$this ->db 
        ->order_by('cont_time','desc')
        ->get('content')->result_array();
        $this->load->view('admin/content/content',['content'=>$content,'links'=>$links]);

    }

    public function desc()
    {
        $cont_id=$this->uri->segment(4);
        // $is_see=$this->uri->segment(5);
        // echo "$is_see";
        $res=$this ->db ->update('content',['is_see'=>1],['cont_id'=>$cont_id]);
        $arr=$this ->db ->where(['cont_id'=>$cont_id])->get('content')->row_array();
        // print_r($arr);
        $this ->load ->view('admin/content/desc',['arr'=>$arr]);
    }
    



}